home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************\
- * file: NBPConfirmName.c *
- * version: 1.06ß *
- * *
- * Confirm an entity by its name, type and zone. This routine is *
- * provided for completeness. ATSend automatically confirms an *
- * entity before sending the message. *
- * ----------------------------------------------------------------- *
- * By: Donald Koscheka *
- * Date: 6-Oct-87 *
- * © Copyright 1987, Apple Computer, Inc. *
- * All Rights Reserved *
- * *
- * ----------------------------------------------------------------- *
- * Modification History *
- * ----------------------------------------------------------------- *
- * Date | By | Description *
- * ----------------------------------------------------------------- *
- * 6-Oct-87 | DK | file created *
- * 5-Nov-87 | DK | added return result *
- * 14-Jan-87 | DK | modified to reflect decoupling of NBP & ATP *
- * 22-Feb-88 | DK | Move all locked handles high *
- * ----------------------------------------------------------------- *
- \*******************************************************************/
-
- /*******************************************************************\
- Build Sequence
-
- C -q2 -g -o "{hpo}"NBPConfirmName.c.o "{nbp}"NBPConfirmName.c
- link -sn Main=NBPConfirmName -sn STDIO=NBPConfirmName ∂
- -sn INTENV=NBPConfirmName -rt XFCN=301 ∂
- -m NBPCONFIRMNAME ∂
- "{hpo}"NBPCONFIRMNAME.c.o "{hpo}"atalkxcmd.c.o "{hpo}"xcmdutils.c.o ∂
- "{CLibraries}"CInterface.o ∂
- "{Libraries}"Interface.o ∂
- -o "{hp}"HyperPeople
-
- \*******************************************************************/
-
- #include <Types.h>
- #include <Memory.h>
- #include <Resources.h>
- #include <OSUtils.h>
- #include <appleTalk.h>
- #include <HyperXCmd.h>
- #include <atalkXCMD.h>
- #include <XCMDUtils.h>
-
- pascal void NBPConfirmName( paramPtr )
- XCmdBlockPtr paramPtr;
- /**********************************
- * ATConfirm
- *
- * In: ParamPtr->params[0] = entityName
- * ParamPtr->params[1] = entityType
- * ParamPtr->params[2] = entityZone
- * ParamPtr->params[3] = count
- * ParamPtr->params[4] = interval
- *
- * Out: True if entity still visible,
- * false otherwise.
- *
- * Defaults:
- * Type = 'HyperPeople'
- * Zone = '*'
- * count = 2
- * interval= 8
- **********************************/
- {
- short total = 0;
- short nextentity = 1;
- short found = 0;
- short result;
- short count, interval;
- char theName[34], theType[34], theZone[34];
- char namestr[100], typestr[34], zonestr[34];
- long temp;
- char **strH;
- Handle entityType = nil;
- EntityName eName;
- AddrBlock eAddr;
- NBPBlock *nbp;
-
- nbp = (NBPBlock *)RetrieveHandle( paramPtr, GLOBALNBPDATA );
- if( !nbp ){
- paramPtr->returnValue = ErrorReturn( DEFAULT_ERROR );
- return;
- }
-
- if( paramPtr->params[0] == nil ){
- /*** can't confirm the name if no name given ***/
- paramPtr->returnValue = ErrorReturn( DEFAULT_ERROR );
- return;
- }
- strcopy( theName, *(paramPtr->params[0]) );
-
- if( !paramPtr->params[1] ){ /*** type not specified ***/
- if( entityType = GetResource('STR ', EntityTypeStr ) ){
- pStrCopy( *entityType, theType );
- p2cstr( theType );
- }
- else{
- paramPtr->returnValue = ErrorReturn( DEFAULT_ERROR );
- return;
- }
- }
- else strcopy( theType, *(paramPtr->params[1]) );
-
- if( !paramPtr->params[2] ){ /*** zone not specified ***/
- theZone[0] = '*';
- theZone[1] = '\0';
- }
- else
- strcopy( theZone, *(paramPtr->params[2]) );
-
-
- if( paramPtr->params[3] ){
- HLock( paramPtr->params[3] );
- c2pstr( *(paramPtr->params[3] ) );
- count = (short)StrToNum( paramPtr, *(paramPtr->params[3]) );
- HUnlock( paramPtr->params[2] );
- }
- else
- count = 2;
-
- if( paramPtr->params[4] ){
- HLock( paramPtr->params[4] );
- c2pstr( *(paramPtr->params[4] ) );
- interval = (short)StrToNum( paramPtr, *(paramPtr->params[4]) );
- HUnlock( paramPtr->params[4] );
- }
- else
- interval = 8;
-
- total = nbp->EntCount;
-
- /*** scan the entity list until we find a match or scan past all entities. ***/
- while( !found ){
- found = ExtractName( nbp, nextentity, &eName, &eAddr );
- pStrCopy( &eName.objStr, namestr );
- p2cstr( namestr );
- pStrCopy( &eName.typeStr, typestr );
- p2cstr( typestr );
- pStrCopy( &eName.zoneStr, zonestr );
- p2cstr( zonestr );
-
- if( (!strCMP( theName, namestr )) &&
- (!strCMP( theType, typestr )) &&
- (!strCMP( theZone, zonestr ))
- ){
- /*** need to compress the string into an entityName ***/
- c2pstr( namestr );
- c2pstr( typestr );
- c2pstr( zonestr );
-
- temp = (long)namestr[0] + 1;
- BlockMove( typestr, namestr+temp, (long)*typestr+1 );
- temp += (long)typestr[0] + 1;
- BlockMove( zonestr, namestr+temp, (long)*zonestr+1 );
-
- found = ConfirmName( nbp, namestr, &eAddr, 2, 8);
- break;
- }
- else{
- ++nextentity;
- found = 0;
- if( nextentity > total )
- break;
- }
- }
- strH = NewHandle( 8 );
- MakeAnswer( found, *strH );
- paramPtr->returnValue = strH;
- }
-